﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Snowy.Dtos
{

    public enum ApiCode
    {
        Success = 200
    }
    public class ApiResult
    {
        public ApiResult()
        {
        }
        public ApiResult(ApiCode _code)
        {
            Code = (int)_code;
            switch (_code)
            {
                case ApiCode.Success:
                    Message = "请求成功";
                    Success = true;
                    break;
                    
                default:
                    break;
            }
            

        }
        public ApiResult(ApiCode _code, string _msg)
        {
            Code = (int)_code;
            Message = _msg;
        }
        public bool Success { get; set; } = true;
        public int Code { get; set; } = (int)ApiCode.Success;
        public string Message { get; set; } = "请求成功";
    }
    public class ApiResult<T> : ApiResult
    {
        public ApiResult(ApiCode _code) : base(_code)
        {
            Data = default(T);
        }
        public ApiResult(ApiCode _code,T _data) : base(_code)
        {
            Data = _data;
        }

        public ApiResult(ApiCode _code, string _msg, T data) : base(_code, _msg)
        {
            Data = data;
        }

        public T Data { set; get; }
    }
}
